package cn.edu.xmu.oomall.comment.dao.bo;


import cn.edu.xmu.javaee.core.aop.CopyFrom;
import cn.edu.xmu.javaee.core.model.bo.OOMallObject;
import cn.edu.xmu.javaee.core.model.dto.UserDto;
import cn.edu.xmu.oomall.comment.dao.CommentDao;
import cn.edu.xmu.oomall.comment.dao.OrderItemDao;
import cn.edu.xmu.oomall.comment.mapper.po.OrderItemPo;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.time.LocalDateTime;

@NoArgsConstructor
@ToString(callSuper = true, doNotUseGetters = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
@CopyFrom(OrderItemPo.class)
public class OrderItem extends OOMallObject {


    private Long id;

    private Long shopId;

    private Long customerId;

    private Long productId;

    private Long commented;

    private CommentDao commentDao;

    private OrderItemDao orderItemDao;

    public Comment createComment(Comment comment, UserDto user) {

        comment.setOrderItemId(this.getId());
        comment.setShopId(this.getShopId());
        comment.setProductId(this.getProductId());
        comment.setStatus(Comment.UNAUDITED);
        // 4. 保存评论
        return commentDao.insert(comment, user);
    }


    public CommentDao getCommentDao() {
        return commentDao;
    }

    public void setCommentDao(CommentDao commentDao) {
        this.commentDao = commentDao;
    }

    public Long getCommented() {
        return commented;
    }

    public void setCommented(Long commented) {
        this.commented = commented;
    }

    public Long getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }

    @Override
    public Long getId() {
        return id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    public OrderItemDao getOrderItemDao() {
        return orderItemDao;
    }

    public void setOrderItemDao(OrderItemDao orderItemDao) {
        this.orderItemDao = orderItemDao;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public Long getShopId() {
        return shopId;
    }

    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }


    public void setGmtCreate(LocalDateTime gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public void setGmtModified(LocalDateTime gmtModified) {
        this.gmtModified = gmtModified;
    }
}
